home *** CD-ROM | disk | FTP | other *** search
- {$F+,R-,S-}
- Unit IntCase;
-
- { - Automatic international case conversion
- based on DOS' built in case conversion table.
- All you need to do is set the country code
- correctly in your CONFIG.SYS.}
-
- { - Note: DOS converts some accented lower case
- characters to normal upper case, which
- means that Upcase can't always be reversed.}
-
- Interface
-
- function Upcase(c:char):char;
- {- Convert character to upper case}
-
- function Locase(c:char):char;
- {- Convert character to lower case}
-
- Implementation
- uses Dos;
-
- var
- DosUpCase : procedure;
- LocaseTranslationTable : array[#128..#255] of char;
-
- function Upcase(c:char):char; external;
- {- Convert character to upper case}
-
- function Locase(c:char):char; external;
- {- Convert character to lower case}
-
- procedure Dummy; external;
- {- Dummy procedure used when a DOS version < 3.0 is used, in which case
- extended character will not be converted.}
-
- {$l intcase}
-
- procedure GetDosCountryInformation;
- {- Get CaseMapCallAddress from DOS, if available}
- var
- Regs:Registers;
-
- {Country Information Block for DOS 3 (from Ray Duncan: Advanced MS-DOS)}
-
- CIB : record
- DateFormat : Word;
- CurrencySymbolString : array[2..6] of char;
- ThousandSeparator : Byte;
- ZeroFiller : Byte;
- DecimalSeparator : Byte;
- ZeroFiller2 : Byte;
- DateSeparator : Byte;
- ZeroFiller3 : Byte;
- TimeSeparator : Byte;
- ZeroFiller4 : Byte;
- CurrencyFormat : Byte;
- DigitsAfterDecimal : Byte;
- TimeFormat : Byte;
- CaseMapCallAddress : Pointer; {Only field we use here}
- DateListSeparator : Byte;
- ZeroFiller5 : Byte;
- Reserved : array[24..33] of byte;
- end;
-
- begin
- DosUpCase := Dummy; {Initialize to Dummy, in case we fail}
- if lo(DosVersion)>2 then {CaseMap supported ?}
- begin
- Regs.ax := $3800;
- Regs.ds := SSeg;
- Regs.dx := ofs(CIB); {ds:dx points to information buffer}
- Intr($21,Regs); {Get country information}
- if not Odd(Regs.flags) then {Check for CF set = failure}
- @DosUpCase := CIB.CaseMapCallAddress;
- end;
- end;
-
- procedure InitLocasetable;
- {- Builds a conversion table for converting characters >= #128
- from upper to lower case.}
- var
- c,cu:char;
- begin
- fillchar(Locasetranslationtable,128,0);
- for c := #128 to #255 do begin
- cu := upcase(c);
- if cu>=#128 then
- if locasetranslationtable[cu]=#0 then
- Locasetranslationtable[cu]:=c;
- end;
- for c := #128 to #255 do
- if locasetranslationtable[c]=#0 then
- Locasetranslationtable[c]:=c;
- end;
-
- begin
- GetDosCountryInformation;
- InitLocaseTable;
- end.